package com.cat.DataStructure04;

import java.io.*;
import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://www.luogu.com.cn/problem/P2657
 * @create 2025/11/24 09:47
 * @since JDK17
 */

public class Solution01 {
    static int MAXN = 11, num1, num2;
    static int[][][]dp = new int[MAXN][MAXN][2];
    static void build() {
        for (int i = 0; i < MAXN; i++) {
            for (int j = 0; j < MAXN; j++) {
                Arrays.fill(dp[i][j], -1);
            }
        }
    }
    static int cnt(int num) {
        if (num == 0) {
            return 1;
        }
        int temp = num / 10, offset = 1, len = 1;
        while (temp > 0) {
            offset *= 10;
            len++;
            temp /= 10;
        }
        build();
        return f(num, len, offset, 10, 0);
    }
    static int f(int num, int len, int offset, int pre, int free) {
        if (len == 0) {
            return 1;
        }
        if (dp[len][pre][free] != -1) {
            return dp[len][pre][free];
        }
        int ans = 0, cur = num / offset % 10;
        if (free == 0) {    //
            if (pre == 10) {    // 一位都没选
                ans += f(num, len - 1, offset / 10, 10, 1);
                for (int i = 1; i < cur; i++) {
                    ans += f(num, len - 1, offset / 10, i, 1);
                }
                ans += f(num, len - 1, offset / 10, cur, 0);
            } else {    // 之前已经选过了
                for (int i = 0; i <= cur; i++) {
                    if (i + 2 <= pre || i >= pre + 2) {
                        if (i == cur) {
                            ans += f(num, len - 1, offset / 10, i, 0);
                        } else {
                            ans += f(num, len - 1, offset / 10, i, 1);
                        }
                    }
                }
            }
        } else {
            if (pre == 10) {    // 前面没选过
                ans += f(num, len - 1, offset / 10, 10, 1); //
                for (int i = 1; i <= 9; i++) {    //
                    ans += f(num, len - 1, offset / 10, i, 1);
                }
            } else {    //
                for (int i = 0; i <= 9; i++) {
                    if (i + 2 <= pre || i >= pre + 2) {
                        ans += f(num, len - 1, offset / 10, i, 1);
                    }
                }
            }
        }
        dp[len][pre][free] = ans;
        return ans;
    }

    static int compute() {
        return cnt(num2) - cnt(num1 - 1);
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        in.nextToken();
        num1 = ((int) in.nval);
        in.nextToken();
        num2 = ((int) in.nval);

        out.println(compute());
        out.flush();
        out.close();
        br.close();
    }
}
